<p><code>if</code> statements with conditions that are always false have the effect of making blocks of code non-functional. <code>if</code>
statements with conditions that are always true are completely redundant, and make the code less readable.</p>
<p>There are three possible causes for the presence of such code: </p>
<ul>
  <li> An if statement was changed during debugging and that debug code has been committed. </li>
  <li> Some value was left unset. </li>
  <li> Some logic is not doing what the programmer thought it did. </li>
</ul>
<p>In any of these cases, unconditional <code>if</code> statements should be removed.</p>
<h2>Noncompliant Code Example</h2>
<pre>
if (true) {
  doSomething();
}
...
if (false) {
  doSomethingElse();
}

if (2 &lt; 3 ) { ... }  // Noncompliant; always false

int i = 0;
int j = 0;
// ...
j = foo();

if (j &gt; 0 &amp;&amp; i &gt; 0) { ... }  // Noncompliant; always false - i never set after initialization

boolean b = true;
//...
if (b || !b) { ... }  // Noncompliant
</pre>
<h2>Compliant Solution</h2>
<pre>
doSomething();
...
</pre>
<h2>See</h2>
<ul>
  <li> <a href="http://cwe.mitre.org/data/definitions/489.html">MITRE, CWE-489</a> - Leftover Debug Code </li>
  <li> <a href="http://cwe.mitre.org/data/definitions/570.html">MITRE, CWE-570</a> - Expression is Always False </li>
  <li> <a href="http://cwe.mitre.org/data/definitions/571.html">MITRE, CWE-571</a> - Expression is Always True </li>
</ul>
<h2>Deprecated</h2>
<p>This rule is deprecated; use {rule:java:S2583} instead.</p>

